import { easing, Node, tween, UIOpacity } from "cc"
import { TIMER } from "../enum"


export const fadeIn = (node: Node, duration = TIMER.FADE): Promise<void> => new Promise(resolve => tween(node.getComponent(UIOpacity))
  .to(duration, { opacity: 255 }, { easing: easing.fade })
  .call(() => resolve())
  .start())

export const fadeOut = (node: Node, duration = TIMER.FADE): Promise<void> => new Promise(resolve => tween(node.getComponent(UIOpacity))
  .to(duration, { opacity: 0 }, { easing: easing.fade })
  .call(() => resolve())
  .start())
